<?php
namespace app\common\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule =   [
        'id'                   => 'require|integer',
        'user_id|用户ID'       => 'require|integer',
        'page|页数'            => 'require|integer',
        'limit|条数'           => 'require|integer',
        'username|账号'        => 'require|length:6,20',
        'nickname|昵称'        => 'require|length:2,20',
        'mobile|联系方式'      => 'require|length:6,20',
        'password|密码'        => 'require|length:6,20',
        'password_old|旧密码'  => 'require|length:6,20',
        'password_new|新密码'  => 'require|length:6,20',
        'avatar|头像'          => 'require|image',
    ];
    
    protected $scene = [
        /** 接口 */
        'show'        => ['user_id'],
        'login'       => ['username', 'password'],
        'setPassword' => ['user_id', 'password_old', 'password_new'],
        'setAvatar'   => ['user_id', 'avatar'],

        /** 后台 */
        'list'       => ['page', 'limit'],
    ];
}